﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Shapes;
using System.Windows.Media;
using System.Windows.Ink;
using System.Windows;
using System.Windows.Controls;

namespace DiagramCreator.Nodes
{
    public class DecissionNode : GenericNode, IDisposable
    {
        #region - Konstruktor -

        public DecissionNode() : base()
        {
            
            Polygon mainShape = new Polygon();
            mainShape.Points.Add(new Point(0, 1));
            mainShape.Points.Add(new Point(1, 0));
            mainShape.Points.Add(new Point(2, 1));
            mainShape.Points.Add(new Point(1, 2));
            mainShape.Points.Add(mainShape.Points[0]);
            mainShape.Fill = (Brush)this.Resources["NodeBgFillGradient"];
            mainShape.Stroke = new SolidColorBrush(Color.FromArgb(255, 10, 10, 10));
            mainShape.StrokeThickness = 0.7;
            mainShape.Width = double.NaN;
            mainShape.Height = double.NaN;
            
            mainShape.Margin = new Thickness(0, 0, 0, 0);           

            this.ShapeGrid.Children.Add(mainShape);
            this.Shape = mainShape;
            this.CanHaveNodeTextField = false;          
            this.IsSizeable = true;

            this.SizeChanged += new SizeChangedEventHandler(DecissionNode_SizeChanged);
        }

        void DecissionNode_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            Polygon p = Shape as Polygon;
            p.Points[0] = new Point(0, ShapeGridHeight / 2);
            p.Points[1] = new Point(ShapeGridWidth / 2, 0);
            p.Points[2] = new Point(ShapeGridWidth, ShapeGridHeight /2);
            p.Points[3] = new Point(ShapeGridWidth / 2, ShapeGridHeight);
            p.Points[4] = p.Points[0];
        }

        #endregion

        #region - IDisposable Members -

        void IDisposable.Dispose()
        {
            
        }

        #endregion
    }
}
